from pylib import models
from pylib import web

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class SearchPerson(web.BaseHandler):
  @web.retry
  def get(self):
    query = self.request.get('query', '').strip()
    values = {
      'query': query,
    }
    if query:
      values['results'] = models.Identity.all().search(query)
    self.render_response('search_person.html', **values)


application = webapp.WSGIApplication([('.*', SearchPerson)])

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()
